<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"/>
    <link rel="stylesheet" th:href="@{/admin/css/pearForm.css}"/>

    <style type="text/css">
        body {
            background-color: #F2F2F2;
        }
    </style>
</head>
<body>

<div class="layui-container">

    <form class="layui-form layui-form-pane" action="/restdoc/project/view">

        <input type="hidden" th:value="${project.id}" id="id">

        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input type="text" id="name" name="name" th:value="${project.name}" lay-verify="required"
                       placeholder="请输入"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <input id="desc" type="text" th:value="${project.desc}" name="desc" placeholder="请输入" autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">应用类型</label>
            <div class="layui-input-block">
                <select name="city" lay-verify="required" id="type">
                    <option value="REST_WEB">REST web应用</option>
                    <option value="DUBBO">Dubbo应用</option>
                    <option value="SPRINGCLOUD">SpringCloud应用</option>
                </select>
            </div>
        </div>
    </form>

</div>

<script th:src="@{/layui/layui.js}"></script>
<script th:src="@{/admin/js/jquery.js}"></script>
<script type="text/javascript" th:inline="javascript">

    var project = [[${project}]];

    if (project.type === 'REST_WEB') {
        $("#type").find("option[value='REST_WEB']").attr("selected",true);
    } else if (project.type === 'DUBBO') {
        $("#type").find("option[value='DUBBO']").attr("selected",true);
    } else if (project.type === 'SPRINGCLOUD') {
        $("#type").find("option[value='SPRINGCLOUD']").attr("selected",true);
    }

    layui.use([
        'util', 'layer',
        'form', 'upload',
        'element', 'jquery'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        msg = layui.layer;
        var layer = layui.layer;

        /* form.on('submit(*)', function (data) {
             $.ajax({
                 type: 'PATCH',
                 dataType: 'JSON',
                 contentType: 'application/json;charset=utf-8',
                 url: '/restdoc/project',
                 data: JSON.stringify(data.field),
                 async: false,
                 success: function (data) {
                     if (data.code === "200") {
                     } else {
                         updateSuccess = true;
                         errorMessage = data.message;
                     }
                 }
             });

             return false;
         });*/
    });

    function getFormData() {
        return {
            "id": $("#id").val(),
            "name": $("#name").val(),
            "desc": $("#desc").val(),
            "type": $("#type option:selected").val()
        };
    }

</script>
</body>
</html>